#!/bin/bash


# 打包
echo "**********************************打包..."
cd /app/java/chuan-zhi/hw-java || { echo "**********************************进入目录失败"; exit 1; }
git pull
if mvn clean package; then
    echo "**********************************打包成功."
else
    echo "**********************************打包失败."
    exit 1
fi

# 启动项目
echo "**********************************重启java..."
docker restart java

echo "**********************************启动容器中的jar包服务..."
if docker exec -i java /bin/sh -c "cd /app/chuan-zhi/hw-java/target && nohup java -jar /app/chuan-zhi/hw-java/target/*.jar > /app/chuan-zhi/hw-java/target/nohup.out 2>&1 &"; then
    echo "**********************************启动容器中的jar包服务成功."
else
    echo "**********************************启动容器中的jar包服务失败."
    exit 1
fi


echo "**********************************结束."

